package com.example.campusannouncement.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@RestController
@RequestMapping("/api/news")
public class NewsController {
    private static final Logger logger = LoggerFactory.getLogger(NewsController.class);

    @GetMapping("/search")
    public String searchNewsByTitle(@RequestParam("title") String title) {
        logger.info("搜索新闻，标题关键词: {}", title);
        // 这里简单返回一个模拟的搜索结果
        return String.format("找到包含 '%s' 的新闻：示例新闻标题", title);
    }

    @GetMapping("/titles")
    public java.util.List<String> getAllNewsTitles() {
        logger.info("获取所有新闻标题");
        // 返回一些示例新闻标题
        return java.util.Arrays.asList(
            "示例新闻1",
            "示例新闻2",
            "示例新闻3"
        );
    }
} 